package com.xhh.stu.entity;

import java.io.Serializable;
import java.util.List;

import com.xhh.stu.cal.Calculate;
import com.xhh.stu.cal.factory.CalculateFactory;

/**
 * 发票
 * <p>2017年1月4日 下午4:37:04</p>
 * @author lijian
 * @version 1.0
 */
public class Invoice implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private List<Goods> goods;
	private double totalPrice;
	private double totalDownPrice=0d;
	
	public double getTotalDownPrice() {
		return totalDownPrice;
	}
	public void setTotalDownPrice(double totalDownPrice) {
		this.totalDownPrice = totalDownPrice;
	}
	public List<Goods> getGoods() {
		return goods;
	}
	public void setGoods(List<Goods> goods) {
		this.goods = goods;
	}
	public double getTotalPrice() {
		return totalPrice;
	}
	public void setTotalPrice(double totalPrice) {
		this.totalPrice = totalPrice;
	}
	public Invoice(List<Goods> goods, double totalPrice) {
		super();
		this.goods = goods;
		this.totalPrice = totalPrice;
	}
	@Override
	public String toString() {
		return "Invoice [totalPrice=" + totalPrice + "]";
	}
	
	public void printInvoice(){
		System.out.println("******<没钱赚商店>购物清单**********");
		Calculate cal=CalculateFactory.getCalCulateInstance("+");
		for(Goods g:goods){
			System.out.println(g.toString());
			this.totalDownPrice=cal.calculate(this.totalDownPrice, g.getDownMoney());
		}
		System.out.println("------------------------------");
		System.out.println("总价:"+this.totalPrice+"(元)");
		System.out.println("节省:"+this.totalDownPrice+"(元)");
		System.out.println("******************************");
	}
	

}
